package de.gameduell.framework.queue {
	import de.gameduell.framework.gui.popup.Popup;
	import de.gameduell.framework.queue.GDAction;

	import flash.events.Event;

	/**
	 * @author dkum
	 */
	public class PopupAction extends GDAction {
		private var popup:Popup;

		public function PopupAction(aPopup:Popup, invokeNow:Boolean = false, aDescription:String = "") {
			popup = aPopup;
			super(popup.show, [], invokeNow, aDescription);
		}

		override public function compute():void {
			popup.addEventListener(Popup.HIDE, onHide);
			popup.show();
		}

		private function onHide(event:Event):void {
			popup.removeEventListener(Popup.HIDE, onHide);
			dispatchEvent(new ActionEvent(ActionEvent.DONE));
		}
	}
}
